package com.example.taco_message_receive.messing.jms;

import com.example.taco_message_receive.messing.KitchenUI;
import com.example.taco_message_receive.messing.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

@Component
public class OrderListener {

    private KitchenUI ui;

    @Autowired
    public OrderListener(KitchenUI ui) {
        this.ui = ui;
    }

    @JmsListener(destination = "tacocloud.order.queue")//消息到达该方法自动调用，并且会把消息中的Order载荷作为参数
    public void receiveOrder(Order order) {
        ui.displayOrder(order);
    }
}
